﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SisLegal.Model;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;

namespace SisLegal.Expedient
{    
    public partial class FiscalFolderDisplayForm : System.Web.UI.Page
    {
        private int ID
        {
            get
            {
                if (Request.QueryString["id"] == null)
                    return 0;
                else
                    return int.Parse(Request.QueryString["id"]);
            }
        }

        protected void Page_Load(object sender, EventArgs e)        {
            
            if (!Page.IsPostBack)
            {
                FiscalFolderManager fiscalFolder = new FiscalFolderManager();
                SisLegal.Model.FiscalFolder fiscal = fiscalFolder.GetById(ID);
                hlEdit.NavigateUrl = "~/Expedient/FiscalFolderEditForm.aspx?id=" + ID.ToString();
                hlUpload.NavigateUrl = "~/Expedient/FiscalFolderUploadForm.aspx?id=" + ID.ToString() + "&type=" + (int)eFileLoad.FiscalFolder_Principal;
                lblNroFiscalFolder.Text = fiscal.NroFiscalFolder;
                lblYear.Text = fiscal.Year.ToString();
                lblFiscalia.Text = fiscal.Fiscalia;
                lblFiscalCargo.Text = fiscal.FiscalCargo;
                lblPoliciaCargo.Text = fiscal.PoliciaCargo;
                lblDenunciante.Text = fiscal.Denunciante;
                lblDenunciado.Text = fiscal.Denunciado;
                lblAgraviado.Text = fiscal.Agraviado;
                lblParticipation_Seal.Text = ((eParticipation_Seal_Fiscal_Folder)fiscal.ParticipationSeal).ToString();
                lblDocumentoInicial.Text = fiscal.DocumentoInicial;
                lblFechaHechos.Text = String.Format("{0:dd/MM/yyyy}", fiscal.FechaHechos); 
                lblFechaNoticicacionSeal.Text = String.Format("{0:dd/MM/yyyy}", fiscal.FechaNoticicacionSeal);
                lblArticle.Text = fiscal.Article.ToString();
                lblMontoPretension.Text = fiscal.MontoPretension.ToString();
                lblMoney.Text = ((eMoney)fiscal.Money).ToString(); 

                lblFechaInicio.Text = String.Format("{0:dd/MM/yyyy}", fiscal.FechaInicio);
                lblType_Process.Text = ((eParticipation_Seal_Fiscal_Folder)fiscal.TypeProcess).ToString();
                lblContingency_Rate.Text = ((eParticipation_Seal_Fiscal_Folder)fiscal.ContingencyRate).ToString();
                lblSumilla.Text = fiscal.Sumilla;
                lblObservaciones.Text = fiscal.Observaciones;

                lblAssigned_Person.Text = ((eParticipation_Seal_Fiscal_Folder)fiscal.AssignedPerson).ToString();
                lblLawyer.Text = ((eParticipation_Seal_Fiscal_Folder)fiscal.Lawyer).ToString();
                lblOrdenServicio.Text = fiscal.OrdenServicio;
                lblNroRecibo.Text = fiscal.NroRecibo;
                lblTerminosReferencia.Text = fiscal.TerminosReferencia;
                lblAbogadoSeal.Text = fiscal.AbogadoSeal;
                lblPracticanteSeal.Text = fiscal.PracticanteSeal;
                lblPhysical_Location_Files.Text = ((eParticipation_Seal_Fiscal_Folder)fiscal.PhysicalLocationFiles).ToString();
            }
        }

        [WebMethod]
        
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]  
        public static string GetFiles(int IDFiscalFolder)
        {
            FileLoadManager file = new FileLoadManager();

            return new JavaScriptSerializer().Serialize(file.GetByIdRef(IDFiscalFolder).ToArray());
            
            //return DateTime.Now.ToString();
        }
    }
}